home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / File.Type.Notes / FTN.D8.0000 < prev    next >
Encoding:
Text File  |  1989-03-22  |  44.5 KB  |  884 lines  |  [04] ASCII Text (0x0000)

  1. Apple II
  2. File Type Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5. File Type:         $D8 (216)
  6. Auxiliary Type:    $0000
  7.  
  8. Full Name:     Audio Interchange File Format File
  9. Short Name:    Audio IFF File
  10.  
  11. Written by:    Matt Deatherage                                     March 1989
  12.  
  13. Files of this type and auxiliary type contain sampled sounds in Apple 
  14. Computer's Audio Interchange File Format (Audio IFF).
  15. _____________________________________________________________________________
  16.  
  17. The Audio Interchange File Format (Audio IFF) provides a standard for storing 
  18. sampled sounds.  The format is quite flexible, allowing the storage of 
  19. monaural or multichannel sampled sounds at a variety of sample rates and 
  20. sample widths.
  21.  
  22. This Note describes version 1.3 (January 4, 1989) of the Audio Interchange 
  23. File Format.  This Note describes Audio IFF as it pertains to Apple II 
  24. developers.  For a copy of the original Audio IFF specification, you may order 
  25. "Audio Interchange File Format v. 1.3" from APDA.
  26.  
  27. Audio IFF conforms to the "EA IFF 85" Standard for Interchange Format Files 
  28. developed by Electronic Arts.
  29.  
  30. Audio IFF is primarily an interchange format, although application designers 
  31. should find it flexible enough to use as a data storage format as well.  If an 
  32. application does choose to use a different storage format, it should be able 
  33. to convert to and from the format defined in this document.  This ability to 
  34. convert will facilitate the sharing of sound data between applications.
  35.  
  36. Audio IFF is the result of several meetings held with music developers over a 
  37. period of ten months during 1987 and 1988.  Apple Computer greatly appreciates 
  38. the comments and cooperation provided by all developers who helped define this 
  39. standard.
  40.  
  41. Another "EA IFF 85" sound storage format is "8SVX" IFF 8-bit Sampled Voice, by 
  42. Electronic Arts.  "8SVX," which handles eight-bit monaural samples, is 
  43. intended mainly for storing sound for playback on personal computers.  Audio 
  44. IFF is intended for use with a larger variety of computers, sampled sound 
  45. instruments, sound software applications, and high fidelity recording devices.
  46.  
  47. The official name for this standard is Audio Interchange File Format.  If an 
  48. application program needs to present the name of this format to a user, such 
  49. as in a "Save As..." dialog box, the name can be abbreviated to Audio IFF.  
  50. Although the Apple IIGS Sampled Instrument format is often abbreviated as 
  51. "ASIF," referring to Audio IFF files by a four-letter abbreviation (i.e., 
  52. "AIFF") in user-level documentation or program-generated messages should be 
  53. avoided.
  54.  
  55.  
  56. The Chunk Concept
  57.  
  58. The "EA IFF 85" Standard for Interchange Format Files defines an overall 
  59. structure for storing data in files.  Audio IFF conforms to the  "EA IFF 85" 
  60. standard.  This Note describes those portions of "EA IFF 85" that are germane 
  61. to Audio IFF.  For a more complete discussion of "EA IFF 85," please refer to 
  62. "EA IFF 85" Standard for Interchange Format Files.
  63.  
  64. Audio IFF, like all IFF-style storage formats, is a series of discrete pieces, 
  65. or "chunks."  Each chunk has an eight-byte "header," which is as follows:
  66.  
  67. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  68.                        ASCII characters in the range $20-$7F.  
  69.                        Spaces may not precede printing 
  70.                        characters, although trailing spaces are 
  71.                        allowed.  Characters outside the range 
  72.                        $20-$7F are forbidden.  A program can 
  73.                        determine how to interpret the chunk data 
  74.                        by examining ckID.
  75. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  76.                        cdID.  You may think of this value as the 
  77.                        offset to the end of the chunk.  Note that 
  78.                        this is a Reverse Long; the bytes are 
  79.                        stored high byte first.
  80. ckData    Chunk        The data, specific to each individual chunk.  There 
  81.                        are exactly ckSize bytes of data here.  If 
  82.                        the length of the chunk is odd, a pad byte 
  83.                        of $00 must be added at the end.  The pad 
  84.                        byte is not included in ckSize.
  85.  
  86. Since Audio IFF is primarily an interchange format, it will come as no 
  87. surprise to find that all constants, such as each chunk's ckSize field, are 
  88. stored in reverse format (the bytes of multiple-byte values are stored with 
  89. the high-order bytes first).  This is true for all constants, which are marked 
  90. in their individual descriptions by the Reverse notation.
  91.  
  92. Note:    All numeric values in this Note are signed unless otherwise 
  93.          noted.  This is different from the normal File Type Note 
  94.          convention.
  95.  
  96. An Audio IFF file is a collection of a number of different types of chunks.  
  97. There is a Common Chunk which contains important parameters describing the 
  98. sampled sound, such as its length and sample rate.  There is a Sound Data 
  99. Chunk which contains the actual audio samples.  There are several other 
  100. optional chunks which define markers, list instrument parameters, store 
  101. application-specific information, etc.  All of these chunks are described in 
  102. detail in this Note.
  103.  
  104.  
  105. File Structure
  106.  
  107. The chunks in an Audio IFF file are grouped together in a container chunk.  
  108. "EA IFF 85" Standard for Interchange Format Files  defines a number of 
  109. container chunks, but the one used by Audio IFF is called a FORM.  A FORM has 
  110. the following format:
  111.  
  112. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  113.                        "FORM."
  114. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  115.                        cdID.  You may think of this value as the 
  116.                        offset to the end of the chunk.  Note that 
  117.                        this is a Reverse Long; the bytes are 
  118.                        stored high byte first.  Also note that 
  119.                        the data portion of the chunk is broken 
  120.                        into two parts, formType and chunks.
  121. formType  4 Bytes      Describes what's in the FORM chunk.  For Audio 
  122.                        IFF files, formType is always "AIFF."  
  123.                        This indicates that the chunks within the 
  124.                        FORM pertain to sampled sound.  A FORM 
  125.                        chunk of formType AIFF is called a FORM 
  126.                        AIFF.
  127. chunks    Bytes        The chunks contained within the FORM.  These chunks 
  128.                        are called local chunks.  A FORM AIFF 
  129.                        along with its local chunks make up an 
  130.                        Audio IFF file.
  131.  
  132. Figure 1 is a pictorial representation of a simple Audio IFF file.  It 
  133. consists of a single FORM AIFF which contains two local chunks, a Common 
  134. Chunk, and a Sound Data Chunk.
  135.  
  136.                         __________________________
  137.                        | FORM AIFF Chunk          |
  138.                        |   chkID = 'FORM'         |
  139.                        |   formType = 'AIFF'      |
  140.                        |    __________________    |
  141.                        |   | Common Chunk     |   |
  142.                        |   |   ckID = 'COMM'  |   |
  143.                        |   |__________________|   |
  144.                        |    __________________    |
  145.                        |   | Sound Data Chunk |   |
  146.                        |   |   ckID = 'SSND'  |   |
  147.                        |   |__________________|   |
  148.                        |__________________________|
  149.    
  150.                       Figure 1-Simple Audio IFF File
  151.  
  152. There are no restrictions on the ordering of local chunks within a FORM AIFF.
  153.  
  154. The FORM AIFF is stored in a file with file type $D8 and auxiliary type $0000.  
  155. Versions 1.2 and earlier of the Audio IFF standard used file type $CB and 
  156. auxiliary type $0000.  This is incorrect; the assignment listed in this Note 
  157. is the correct assignment.  Applications which use Audio IFF files with the 
  158. older assignment should not perform adversely, since no one should be creating 
  159. files of any kind with the older assignment.  However, we strongly urge 
  160. developers to update their applications as soon as possible to only create 
  161. Audio IFF files with file type $D8 and auxiliary type $0000.
  162.  
  163. Audio IFF files may be identified in other file systems as well.  On a 
  164. Macintosh under MFS or HFS, the FORM AIFF is stored in the data fork of a file 
  165. with file type "AIFF."  This is the same as the formType of the FORM AIFF.
  166.  
  167. Note:    Applications should not store any data in the resource fork of 
  168.          an Audio IFF file, since this information may not be preserved by 
  169.          all applications or in translation to foreign file systems.  
  170.          Applications can use the Application Specific Chunk, described 
  171.          later in this Note, to store extra information specific to their 
  172.          application.
  173.  
  174. In file systems that use file extensions, such as MS-DOS or UNIX, it is 
  175. recommended that Audio IFF file names have the extension ".AIF."
  176.  
  177. A more detailed visual example of an Audio IFF file may be found later in this 
  178. Note.  Please refer to it as often as necessary while reading the remainder of 
  179. this Note.
  180.  
  181.  
  182. Local Chunk Types
  183.  
  184. The formats of the different local chunk types found within a FORM AIFF are 
  185. described in the following sections, as are their ckIDs.
  186.  
  187. There are two types of chunks:  required and optional.  The Common Chunk is 
  188. required.  The Sound Data chunk is required if the sampled sound has a length 
  189. greater than zero.  All other chunks are optional.  All applications that use 
  190. FORM AIFF must be able to read the required chunks and can choose to 
  191. selectively ignore the optional chunks.  A program that copies a FORM AIFF 
  192. should copy all the chunks in the FORM AIFF, even those it chooses not to 
  193. interpret the optional chunks.
  194.  
  195. To ensure that this standard remains usable by all developers across machine 
  196. families, only Apple Computer, Inc. should define new chunk types for FORM 
  197. AIFF.  If you have suggestions for new chunk types, Apple is happy to listen.  
  198. Please send all comments to the address listed in "About File Type Notes" to 
  199. the attention of Audio IFF Suggestions.
  200.  
  201.  
  202. The Common Chunk
  203.  
  204. The Common Chunk describes fundamental parameters of the sampled sound.
  205.  
  206. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  207.                        "COMM."
  208. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  209.                        cdID.  For the Common Chunk, this is 
  210.                        always 18.
  211. numChannels            The number of audio channels for the 
  212. Rev. Word              sound.  A value of 1 means monophonic 
  213.                        sound, 2 means stereo, 4 means four-
  214.                        channel sound, and so on.  Any number of 
  215.                        audio channels may be represented.  The 
  216.                        actual sounds samples are stored in the 
  217.                        Sound Data Chunk.
  218. numSampleFrames        The number of sample frames in the Sound Data 
  219. Rev. Unsigned Long     Chunk.  Sample frames are described below.
  220.                        Note that numSampleFrames is the number of
  221.                        sample frames, not the number of bytes nor the 
  222.                        number of sample points (also described 
  223.                        below) in the Sound Data Chunk.  The total 
  224.                        number of sample points in the file is 
  225.                        numSampleFrames multiplied by numChannels.
  226. sampleSize Rev. Word   The number of bits in each sample point.  
  227.                        This can be any number from 1 to 32.
  228. sampleRate             The sample Rate at which the sound is 
  229. Rev. Extended          to be played back, in sample frames per 
  230.                        second.
  231.  
  232. One, and only one, Common Chunk is required in every FORM AIFF.
  233.  
  234.  
  235. Sample Points and Sample Frames
  236.  
  237. A large part of interpreting Audio IFF files revolves around the two concepts 
  238. of sample points and sample frames.
  239.  
  240. A sample point is a value representing a sample of a sound at a given point in 
  241. time.  A sample point may be from 1 to 32 bits wide, as determined by 
  242. sampleSize in the Common Chunk.  Sample points are stored in an integral 
  243. number of contiguous bytes.  One- to eight-bit wide sample points are stored 
  244. in one byte, 9- to 16-bit wide sample points are stored in two bytes, 17- to 
  245. 24-bit wide sample points are stored in three bytes, and 25- to 32-bit wide 
  246. sample points are stored in four bytes (most significant byte first).  When 
  247. the width of a sample point is not a multiple of eight bits, the sample point 
  248. data is left justified, with the remaining bits zeroed.  An example case is 
  249. illustrated in Figure 2.  A 12-bit sample point, binary 101000010111, is 
  250. stored left justified in two bytes.  The remaining bits are set to zero.
  251.  
  252.      ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
  253.     |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
  254.     | 1   0   1   0   0   0   0   1 | 0   1   1   1   0   0   0   0 |
  255.     |___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
  256.      <---------------------------------------------> <------------->
  257.           12 bit sample point is left justified         rightmost
  258.                                                         4 bits are
  259.                                                         zero padded
  260.  
  261.                       Figure 2-A 12-Bit Sample Point
  262.  
  263. Sample frames are sets of sample points which are interleaved for multichannel 
  264. sound.  Single sample points from each channel are interleaved such that each 
  265. sample frame is a sample point from the same moment in time for each channel 
  266. available.  This is illustrated in Figure 3 for the stereo (two channel) case.
  267.  
  268.                    sample      sample              sample
  269.                    frame 0     frame 1             frame N
  270.                  _____ _____ _____ _____         _____ _____
  271.                 | ch1 | ch2 | ch1 | ch2 | . . . | ch1 | ch2 |
  272.                 |_____|_____|_____|_____|       |_____|_____|
  273.                              _____
  274.                             |     | = one sample point
  275.                             |_____|
  276.  
  277.                 Figure 3-Sample Frames for Multichannel Sound
  278.  
  279. For monophonic sound, a sample frame is a single sample point.  For 
  280. multichannel sounds, you should follow the conventions in Figure 4.
  281.  
  282.                                        channel
  283.                1          2          3          4          5          6
  284.            __________ __________ __________ __________ __________ __________
  285.           | left     | right    |          |          |          |          |
  286. stereo    |          |          |          |          |          |          |
  287.           |__________|__________|__________|__________|__________|__________|
  288.           | left     | right    | center   |          |          |          |
  289. 3 channel |          |          |          |          |          |          |
  290.           |__________|__________|__________|__________|__________|__________|
  291.           | front    | front    | rear     | rear     |          |          |
  292. quad      | left     | right    | left     | right    |          |          |
  293.           |__________|__________|__________|__________|__________|__________|
  294.           | left     | center   | right    | surround |          |          |
  295. 4 channel |          |          |          |          |          |          |
  296.           |__________|__________|__________|__________|__________|__________|
  297.           | left     | left     | center   | right    | right    | surround |
  298. 6 channel |          | center   |          |          | center   |          |
  299.           |__________|__________|__________|__________|__________|__________|
  300.  
  301.            Figure 4-Sample Frame Conventions for Multichannel Sound
  302.  
  303. Note:    Portions of Figure 4 do not follow the Apple IIGS standard of 
  304.          right on even channels and left on odd channels.  The portions 
  305.          that do follow this convention usually use channel two for right 
  306.          instead of channel zero as most Apple IIGS standards.  Be prepared 
  307.          to interpret data accordingly.
  308.  
  309. Sample frames are stored contiguously in order of increasing time.  The sample 
  310. points within a sample frame are packed together; there are no unused bytes 
  311. between them.  Likewise, the sample frames are packed together with no pad 
  312. bytes.
  313.  
  314.  
  315. The Sound Data Chunk
  316.  
  317. The Sound Data Chunk contains the actual sample frames.
  318.  
  319. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  320.                        "SSND."
  321. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  322.                        cdID.
  323. offset                 Determines where the first sample 
  324. Rev. Unsigned Long     frame in the soundData starts, in bytes.  
  325.                        Most applications will not use offset and 
  326.                        should set it zero.  Use for a non-zero 
  327.                        offset is explained below.
  328. blockSize              Used in conjunction with offset 
  329. Rev. Unsigned Long     for block-aligning sound data.  It 
  330.                        contains the size in bytes of the blocks 
  331.                        to which soundData is aligned.  As with 
  332.                        offset, most applications will not use 
  333.                        blockSize and should set it to zero.  More 
  334.                        information on blockSize is given below.
  335. soundData Bytes        Contains the actual sample frames that make up 
  336.                        the sound.  The number of sample frames in 
  337.                        the soundData is determined by the 
  338.                        numSampleFrames parameter in the Common 
  339.                        Chunk.
  340.  
  341. The Sound Data Chunk is required unless the numSampleFrames field in the 
  342. Common Chunk is zero.  A maximum of one Sound Data Chunk may appear in a FORM 
  343. AIFF.
  344.  
  345. Block-Aligning Sound Data
  346.  
  347. There may be some applications that, to ensure real time recording and 
  348. playback of audio, wish to align sampled sound data with fixed-size blocks.  
  349. This alignment can be accomplished with the offset and blockSize parameters of 
  350. the Sound Data Chunk, as shown in Figure 5.
  351.  
  352.         ____________ __________________________________ ____________
  353.        |\\ unused \\|          sample frames           |\\ unused \\|
  354.        |____________|__________________________________|____________|
  355.        <-- offset --><- numSampleFrames sample frames ->
  356.  
  357.     |   blockSize   |               |               |               |
  358.     |<- bytes     ->|               |               |               |
  359.     |_______________|_______________|_______________|_______________|
  360.        block N-1       block N         block N+1       block N+2
  361.  
  362.                      Figure 5-Block-Aligned Sound Data
  363.  
  364. In Figure 5, the first sample frame starts at the beginning of block N.  This 
  365. is accomplished by skipping the first offset bytes of the soundData.  Note 
  366. too, that the soundData bytes can extend beyond valid sample frames, allowing 
  367. the soundData bytes to end on a block boundary as well.
  368.  
  369. The blockSize specifies the size in bytes of the block to which you would 
  370. align the sound data.  A blockSize of zero indicates that the sound data does 
  371. not need to be block-aligned.  Applications that don't care about block 
  372. alignment should set the blockSize and offset to zero when creating Audio IFF 
  373. files.  Applications that write block-aligned sound data should set blockSize 
  374. to the appropriate block size.  Applications that modify an existing Audio IFF 
  375. file should try to preserve alignment of the sound data, although this is not 
  376. required.  If an application does not preserve alignment, it should set the 
  377. blockSize and offset to zero.  If an application needs to realign sound data 
  378. to a different sized block, it should update blockSize and offset accordingly.
  379.  
  380.  
  381. The Marker Chunk
  382.  
  383. The Marker Chunk contains markers that point to positions in the sound data.  
  384. Markers can be used for whatever purposes an application desires.  The 
  385. Instrument Chunk, defined later in this Note, uses markers to mark loop 
  386. beginning and end points.
  387.  
  388. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  389.                        "MARK."
  390. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  391.                        cdID.
  392. numMarkers             The number of markers (defined 
  393. Rev. Unsigned Word     below) in the Marker Chunk.  If non-zero, 
  394.                        this is followed by the markers 
  395.                        themselves.  Because all fields in a 
  396.                        marker are an even number of bytes, the 
  397.                        length of any marker will always be even.  
  398.                        Thus, markers are packed together with no 
  399.                        unused bytes between them, although the 
  400.                        markers themselves need not be ordered in 
  401.                        any particular manner.
  402. Marker    Markers      Defined below.
  403.  
  404. A marker has the following format:
  405.  
  406. MarkerID  Rev. Word    The ID for this marker.  This is a number 
  407.                        that uniquely identifies the marker within 
  408.                        a FORM AIFF.  The number can be any 
  409.                        positive, non-zero integer, as long as no 
  410.                        other marker within the same FORM AIFF has 
  411.                        the same ID.
  412.  
  413. position               Determines the marker's position 
  414. Rev. Unsigned Long     in the sound data.  Markers conceptually 
  415.                        fall between two sample frames.  A marker 
  416.                        that falls before the first sample frame 
  417.                        in the sound data is at position zero, 
  418.                        while a marker that falls between the 
  419.                        first and second sample frame in the sound 
  420.                        data is at position one.  Units for 
  421.                        position are sample frames, not bytes nor 
  422.                        sample points.
  423. markerName             Pascal-type string containing the name of the 
  424. String                 mark.
  425.  
  426.                               Sample Frames
  427.              ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ 
  428.             |   |   |   |   |   |   |   |   |   |   |   |   |
  429.             |___|___|___|___|___|___|___|___|___|___|___|___|
  430.             ^                   ^                           ^
  431.         position 0          position 5                  position 12
  432.  
  433.                  Figure 6-Sample Frame Marker Positions
  434.  
  435. Note:    Some "EA IFF 85" files store strings as C-style strings (null 
  436.          terminated).  Audio IFF uses Pascal-style (length byte) strings 
  437.          because they are easier to skip over when scanning a file or a 
  438.          chunk.
  439.  
  440. The Marker Chunk is optional.  No more than one Marker Chunk can appear in a 
  441. FORM AIFF.
  442.  
  443.  
  444. The Instrument Chunk
  445.  
  446. The Instrument Chunk defines basic parameters that an instrument, such as a 
  447. sample, could use to play the sound data.
  448.  
  449. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  450.                        "INST."
  451. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  452.                        cdID.  For the Instrument Chunk, this 
  453.                        field is always 20.
  454. baseNote  Byte         The note at which the instrument plays the sound 
  455.                        data without pitch modification.  Units 
  456.                        are MIDI (Musical Instrument Digital 
  457.                        Interface) note numbers, and are in the 
  458.                        range 0 through 127.  Middle C is 60.
  459. detune    Byte         Determines how much the instrument should alter the 
  460.                        pitch of the sound when it is played .  
  461.                        Units are cents (1/100 of a semitone), and 
  462.                        range from -50 to +50.  Negative numbers 
  463.                        mean that the pitch of the sound should be 
  464.                        lowered, while positive numbers mean that 
  465.                        it should be raised.
  466. lowNote   Byte         Suggested lowest note on a keyboard for playback of 
  467.                        the sound data.  The sound data should be 
  468.                        played if the instrument is requested to 
  469.                        play a note between the lowNote and 
  470.                        highNote, inclusive.  The base note does 
  471.                        not have to be within this range.  Units 
  472.                        for lowNote and highNote are MIDI note 
  473.                        values.
  474. highNote  Byte         Suggested highest note on a keyboard for playback 
  475.                        of the sound data.  See the description of 
  476.                        lowNote above.
  477. lowVelocity    Byte    The low end of the suggested range of 
  478.                        velocities for playback of the sound data.  
  479.                        The sound data should be played if the 
  480.                        note-on velocity is between lowVelocity 
  481.                        and highVelocity, inclusive.  Units are 
  482.                        MIDI velocity values, 1 (lowest velocity) 
  483.                        through 127 (highest velocity).
  484. highVelocity   Byte    The high end of the suggested range of 
  485.                        velocities for playback of the sound data.  
  486.                        See the description of lowVelocity above.
  487. gain      Rev. Word    The amount by which to change the gain of the 
  488.                        sound when it is played.  Units are 
  489.                        decibels.  For example, 0 dB means no 
  490.                        change, 6 dB means double the value of 
  491.                        each sample point, while -6 dB means halve 
  492.                        the value of each sample point.
  493. sustainLoop    Loop    A loop that is to be played when an instrument 
  494.                        is sustaining a sound.  The format of 
  495.                        loops is described below.
  496. releaseLoop    Loop    A loop that is to be played when an instrument 
  497.                        is in the release phase of playing back a 
  498.                        sound.  The release phase usually occurs 
  499.                        after a key on an instrument is released.  
  500.                        The format of loops is described below.
  501.  
  502.  
  503. Loops
  504.  
  505. Sound data can be looped, allowing a portion of the sound to be repeated to 
  506. lengthen the sound.  A loop is marked with two points, a begin position and an 
  507. end position.  There are two ways to play a loop, forward looping and 
  508. forward/backward looping.  In the case of forward looping, playback begins at 
  509. the beginning of the sound, continues past the begin position and continues to 
  510. the end position, at which point playback starts again at the begin position.  
  511. The segment between the begin and end positions, called the loop segment, is 
  512. played repeatedly until interrupted by a user action, such as the release of a 
  513. key on a sampling instrument.
  514.  
  515.                    ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ 
  516.     sample frames |   |   |   |<--- loop segment ---->|   |   |   |
  517.                   |___|___|___|___|___|___|___|___|___|___|___|___|
  518.                               ^                       ^
  519.                         begin position           end position
  520.  
  521.                         Figure 7-Sample Frame Looping
  522.  
  523. With forward/backward looping, the loop segment is first played from the begin 
  524. position to the end position, and then played backwards from the end position 
  525. to the begin position.  This flip-flop pattern is repeated over and over again 
  526. until interrupted.
  527.  
  528. The following structure describes a loop:
  529.  
  530. playMode    Rev. Word    The type of looping to be performed.
  531.                          0 = no looping
  532.                          1 = Forward looping
  533.                          2 = Forward/Backward looping
  534.                          If 0 is specified, the loop points are
  535.                          ignored during playback.
  536. beginLoop   Rev. Word    A Marker ID of the marker to the begin 
  537.                          position.
  538. endLoop     Rev. Word    A Marker ID of the marker to the end 
  539.                          position.  The begin position must be less 
  540.                          than the end position.  If this is not the 
  541.                          case, the loop segment has zero or 
  542.                          negative length and no looping occurs.
  543.  
  544. The Instrument Chunk is optional.  No more than one Instrument Chunk can 
  545. appear in a FORM AIFF.
  546.  
  547. ASIF Note:    The Apple IIGS Sampled Instrument Format also defines a 
  548.               chunk with ID of "INST," which is not the same as the Audio 
  549.               IFF Instrument Chunk.  A good way to tell the two chunks 
  550.               apart in generic IFF-style readers is by the ckSize fields.  
  551.               The Audio IFF Instrument Chunk's ckSize field is always 20, 
  552.               whereas the Apple IIGS Sampled Instrument Format Instrument 
  553.               Chunk's ckSize field, for structural reasons, can never be 
  554.               20.
  555.  
  556.  
  557. The MIDI Data Chunk
  558.  
  559. The MIDI Data Chunk can be used to store MIDI data.  Please refer to Musical 
  560. Instrument Digital Interface Specification 1.0, available from the 
  561. International MIDI Association, for more details on MIDI.
  562.  
  563. The primary purpose of this chunk is to store MIDI System Exclusive messages, 
  564. although other types of MIDI data can be stored in the block as well.  As more 
  565. instruments come to market, they will likely have parameters that have not 
  566. been included in the Audio IFF specification.  The MIDI System Exclusive 
  567. messages for these instruments may contain many parameters that are not 
  568. included in the Instrument Chunk.  For example, a new sampling instrument may 
  569. have more than the two loops defined in the Instrument Chunk.  These loops 
  570. will likely be represented in the MIDI System Exclusive message for the new 
  571. machine.  This MIDI System Exclusive message can be stored in the MIDI Data 
  572. Chunk.
  573.  
  574. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  575.                        "MIDI."
  576. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  577.                        cdID.
  578. MIDIdata               A stream of MIDI Data.
  579. Unsigned Bytes
  580.  
  581. The MIDI Data Chunk is optional.  Any number of MIDI Data Chunks may exist in 
  582. a FORM AIFF.  If MIDI System Exclusive messages for several instruments are to 
  583. be stored in a FORM AIFF, it is better to use one MIDI Data Chunk per 
  584. instrument than one big MIDI Data Chunk for all of the instruments.
  585.  
  586.  
  587. The Audio Recording Chunk
  588.  
  589. The Audio Recording Chunk contains information pertinent to audio recording 
  590. devices.
  591.  
  592. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  593.                        "AESD."
  594. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  595.                        cdID.  For the Audio Recording Chunk, this 
  596.                        value is always 24.
  597. AESChannelStatusData   These 24 bytes are specified in 
  598. 24 Bytes               the AES Recommended Practice for Digital 
  599.                        Audio Engineering--Serial Transmission 
  600.                        Format for Linearly Represented Digital 
  601.                        Audio Data, section 7.1, Channel Status 
  602.                        Data.  This document describes a format 
  603.                        for real-time digital transmission of 
  604.                        digital audio between audio devices.  This 
  605.                        information is duplicated in the Audio 
  606.                        Recording Chunk for convenience.  Bits 2, 
  607.                        3, and 4 of byte zero are of general 
  608.                        interest as they describe recording 
  609.                        emphasis.
  610.  
  611. The Audio Recording Chunk is optional.  No more than one Audio Recording Chunk 
  612. may appear in a FORM AIFF.
  613.  
  614.  
  615. The Application Specific Chunk
  616.  
  617. The Application Specific Chunk can be used for any purposes whatsoever by 
  618. developers and application authors.  For example, an application that edits 
  619. sounds might want to use this chunk to store editor state parameters such as 
  620. magnification levels, last cursor position, etc.
  621.  
  622. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  623.                        "APPL."
  624. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  625.                        cdID.  For the Audio Recording Chunk, this 
  626.                        value is always 24.
  627. OSType    4 Bytes      Identifies a particular application.  For Apple 
  628.                        II applications, these four bytes should 
  629.                        always be 'pdos' ($70 $64 $6F $73).  In 
  630.                        this case, the beginning of the data area 
  631.                        is defined to be a Pascal string 
  632.                        containing the name of the application.  
  633.                        For Macintosh applications, this is simply 
  634.                        the four-character signature as registered 
  635.                        with Developer Technical Support.
  636. AppSignature  String   Pascal string identifying the application.
  637. data          Bytes    Data specific to the application.
  638.  
  639. Note:    AppSignature does not exist unless OSType is "pdos."  In all 
  640.          other cases, the data area starts immediately following the OSType 
  641.          field.
  642.  
  643. The Application Specific Chunk is optional.  Any number of Application 
  644. Specific Chunks may exist in a single FORM AIFF.
  645.  
  646.  
  647. The Comments Chunk
  648.  
  649. The Comments Chunk is used to store comments in the FORM AIFF.  "EA IFF 85" 
  650. has an Annotation Chunk (used in ASIF) that can be used for comments, but the 
  651. Comments Chunk has two features not found in the "EA IFF 85" chunk.  They are 
  652. a time-stamp for the comment and a link to a marker.
  653.  
  654. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  655.                        "COMT."
  656. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  657.                        cdID.
  658. numComments            The number of comments in the 
  659. Rev. Unsigned Word     Comments Chunk.  This is followed by the 
  660.                        comments themselves.  Comments are always 
  661.                        an even number of bytes in length, so 
  662.                        there is no padding between comments in 
  663.                        the Comments Chunk.
  664. Comment   Comment      The comments.  There are numComments of them.
  665.  
  666. The format of a comment is described below:
  667.  
  668. timeStamp Rev. Unsigned Long  Indicates when the comment was 
  669.                               created.  Units are the number of seconds 
  670.                               since 12:00 a.m. (midnight), January 1, 
  671.                               1904.  This is the standard Macintosh time 
  672.                               format.  Macintosh routines to manipulate 
  673.                               this time stamp may be found in Inside 
  674.                               Macintosh, Volume II.
  675.  
  676. Note:    The routine to convert timeStamp into a standard GS/OS date, 
  677.          as described in the Audio IFF 1.3 specification, is not available 
  678.          at this time.
  679.  
  680. marker    Rev. Word           A Marker ID.  If this comment is linked to a 
  681.                               marker (to store a long description of a 
  682.                               marker as a comment, for example), this is 
  683.                               the ID of that marker.  Otherwise marker 
  684.                               is zero, indicating there is no such link.
  685. count     Rev. Word           Count of the number of characters in the 
  686.                               following text.  By using a word instead 
  687.                               of a byte, much larger comments may be 
  688.                               created.
  689. text      Bytes               The comment itself.  If the text is an odd 
  690.                               number of bytes in length, it must be padded
  691.                               with a zero byte to ensure that it is an even 
  692.                               number of bytes in length.  If the pad 
  693.                               byte is present, it is not included in 
  694.                               count.
  695.  
  696. The Comments Chunk is optional.  No more than one Comments Chunk may appear in 
  697. a single FORM AIFF.
  698.  
  699.  
  700. The Text Chunks
  701.  
  702. These four chunks are included in the definition of every "EA IFF 85" file.  
  703. All are text chunks; their data portion consists solely of text.  Each of 
  704. these chunks is optional.
  705.  
  706. The Name Chunk
  707.  
  708. This chunk names the sampled sound.
  709.  
  710. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  711.                        "NAME."
  712. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  713.                        cdID.
  714. Name      Bytes        ASCII characters ($20-$7F) representing the name.  
  715.                        There should be ckSize characters.
  716.  
  717. No more than one Name Chunk may exist within a FORM AIFF.
  718.  
  719. The Author Chunk
  720.  
  721. This chunk can be used to identify the creator of a sampled sound.
  722.  
  723. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  724.                        "AUTH."
  725. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  726.                        cdID.
  727. author    Bytes        ASCII characters ($20-$7F) representing the name of 
  728.                        the author of the sampled sound.  There 
  729.                        should be ckSize characters.
  730.  
  731. No more than one Author Chunk may exist within a FORM AIFF.
  732.  
  733. The Copyright Chunk
  734.  
  735. The Copyright Chunk contains a copyright notice for the sound.  The copyright 
  736. contains a date followed by the copyright owner.  The chunk ID "(c) " serves 
  737. as the copyright character ((C)).  For example, a Copyright Chunk containing 
  738. the text "1989 Apple Computer, Inc." means "(C) 1989 Apple Computer, Inc."
  739.  
  740. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  741.                        "(c) ."
  742. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  743.                        cdID.  You may think of this value as the 
  744.                        offset to the end of the chunk.
  745. notice    Bytes        ASCII characters ($20-$7F) representing a copyright 
  746.                        notice for the voice or collection of 
  747.                        voices.  There should be ckSize 
  748.                        characters.
  749.  
  750. No more than one Copyright Chunk may exist within a FORM AIFF.
  751.  
  752. The Annotation Chunk
  753.  
  754. Use of this comment is discouraged within FORM AIFF.  The more powerful 
  755. Comments Chunk should be used instead.
  756.  
  757. ckID      4 Bytes      The ID for this chunk.  These four bytes must be 
  758. "ANNO."
  759. ckSize    Rev. Long    The length of this chunk, excluding ckSize and 
  760.                        cdID.  You may think of this value as the 
  761.                        offset to the end of the chunk.  Note that 
  762.                        this is a Reverse Long; the bytes are 
  763.                        stored high byte first.
  764. author    Bytes        ASCII characters ($20-$7F) representing the name of 
  765.                        the author of the voices or collection of 
  766.                        voices.  There should be ckSize 
  767.                        characters.
  768.  
  769. Many Annotation Chunks may exist within a FORM AIFF.
  770.  
  771.  
  772. Chunk Precedence
  773.  
  774. Several of the local chunks for FORM AIFF may contain duplicate information.  
  775. For example, the Instrument Chunk defines loop points and MIDI System 
  776. Exclusive data in the MIDI Data Chunk may also define loop points.  What 
  777. happens if these loop points are different?  How is an application supposed to 
  778. loop the sound?  Such conflicts are resolved by defining a precedence for 
  779. chunks.  This precedence is illustrated in Figure 8.
  780.  
  781.                        Common Chunk           Highest Precedence
  782.                             |
  783.                      Sound Data Chunk
  784.                             |
  785.                        Marker Chunk
  786.                             |
  787.                      Instrument Chunk
  788.                             |
  789.                        Comment Chunk
  790.                             |
  791.                         Name Chunk
  792.                             |
  793.                        Author Chunk
  794.                             |
  795.                       Copyright Chunk
  796.                             |
  797.                       Annotation Chunk
  798.                             |
  799.                    Audio Recording Chunk
  800.                             |
  801.                       MIDI Data Chunk
  802.                             |
  803.                  Application Specific Chunk   Lowest Precedence
  804.  
  805.                          Figure 8-Chunk Precedence
  806.  
  807. The Common Chunk has the highest precedence, while the Application Specific 
  808. Chunk has the lowest.  Information in the Common Chunk always takes precedence 
  809. over conflicting information in any other chunk.  The Application Specific 
  810. Chunk always loses in conflicts with other chunks.  By looking at the chunk 
  811. hierarchy, for example, one sees that the loop points in the Instrument Chunk 
  812. take precedence over conflicting loop points found in the MIDI Data Chunk.
  813.  
  814. It is the responsibility of applications that write data into the lower 
  815. precedence chunks to make sure that the higher precedence chunks are updated 
  816. accordingly.
  817.  
  818. Figure 9 (on the following page) illustrates an example of a FORM AIFF.  An 
  819. Audio IFF file is simple a file containing a single FORM AIFF.  The FORM AIFF 
  820. is stored in the data fork of file systems that can handle resource forks.
  821.  
  822.  
  823. Further Reference
  824. _____________________________________________________________________________
  825.     o    Inside Macintosh, Volume II
  826.     o    Apple Numerics Manual, Second Edition
  827.     o    File Type Note File Type $D8, Auxiliary Type $0002, Apple IIGS Sampled 
  828.          Instrument Format
  829.     o    Audio Interchange File Format v1.3  (APDA)
  830.     o    AES Recommended Practice for Digital Audio Engineering--Serial 
  831.          Transmission Format for Linearly Represented Digital Audio Data, Audio 
  832.          Engineering Society, 60 East 42nd Street, New York, NY 10165
  833.     o    MIDI:  Musical Instrument Digital Interface, Specification 1.0, the 
  834.          International MIDI Association.
  835.     o    "EA IFF 85" Standard for Interchange Format Files (Electronic Arts)
  836.     o    "8SVX" IFF 8-bit Sampled Voice (Electronic Arts)
  837.  
  838.  
  839.      _____________________________________________________________________
  840.     | FORM AIFF                                                           |
  841.     |                          _____________                              |
  842.     |                    ckID |_ 'FORM' ____|                             |
  843.     |                  ckSize |_ 176516 ____|                             |
  844.     |  _____________ formType |_ 'AIFF' ____| __________________________  |
  845.     | | Common           ckID |_ 'COMM' ____|                           | |
  846.     | | Chunk          ckSize |_ 18 ________|                           | |
  847.     | |           numChannels |_ 2 ___|_____                            | |
  848.     | |       numSampleFrames |_ 88200 _____|                           | |
  849.     | |            sampleSize |_ 16 __|_______________________________  | |
  850.     | |___________ sampleRate |_ 44100.00 ____________________________| | |
  851.     | | Marker           ckID |_ 'MARK' _____|                          | |
  852.     | | Chunk          ckSize |_ 34 _________|                          | |
  853.     | |            numMarkers |_ 2 ___|                                 | |
  854.     | |                    id |_ 1 ___|_______                          | |
  855.     | |              position |_ 44100 ___ ___|___ ___ ___ ___ ___ ___  | |
  856.     | |            markerName | 8 |'b'|'e'|'g'|' '|'l'|'o'|'o'|'p'| 0 | | |
  857.     | |                    id |_ 2 ___|_______                          | |
  858.     | |              position |_ 88200 _______|___ ___ ___ ___ ___ ___  | |
  859.     | |___________ markerName | 8 |'e'|'n'|'d'|' '|'l'|'o'|'o'|'p'| 0 | | |
  860.     | | Instrument       ckID |_ 'INST' ______|                         | |
  861.     | | Chunk          ckSize |_ 20 __________|                         | |
  862.     | |              baseNote | 60|                                     | |
  863.     | |                detune | -3|                                     | |
  864.     | |               lowNote | 57|                                     | |
  865.     | |              highNote | 63|                                     | |
  866.     | |           lowVelocity | 1 |                                     | |
  867.     | |          highVelocity |127|__                                   | |
  868.     | |                  gain |_ 6 __|                                  | |
  869.     | |  sustainLoop.playMode |_ 1 __|                                  | |
  870.     | | sustainLoop.beginLoop |_ 1 __|                                  | |
  871.     | |   sustainLoop.endLoop |_ 2 __|                                  | |
  872.     | |  releaseLoop.playMode |_ 0 __|                                  | |
  873.     | | releaseLoop.beginLoop |_ - __|                                  | |
  874.     | |__ releaseLoop.endLoop |_ - __|__________________________________| |
  875.     | | Sound            ckID |_ 'SSND' ______|                         | |
  876.     | | Data           ckSize |_ 176408 ______|                         | |
  877.     | | Chunk          offset |_ 0 ___________|                         | |
  878.     | |             blockSize |_ 0 ___________|        _______ _______  | |
  879.     | |             soundData |_ch 1 _|_ch 2 _| . . . |_ch 1 _|_ch 2 _| | |
  880.     | |                       first sample frame   88200th sample frame | |
  881.     | |_________________________________________________________________| |
  882.     |_____________________________________________________________________|
  883.  
  884.                          Figure 9-Sample FORM AIFF